package com.example.merchantdemo.paymentstart.controller;

import com.example.merchantdemo.paymentstart.dto.ConfirmedReceiptAndCoinReleaseReq;
import com.example.merchantdemo.paymentstart.dto.InitialToSellCoinReq;
import com.example.merchantdemo.paymentstart.dto.PlatformResponse;
import com.example.merchantdemo.paymentstart.dto.QueryMatchingTotalPriceReq;
import com.example.merchantdemo.paymentstart.service.SellCoinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/sellCoin")
public class SellCoinController {

    @Autowired
    private SellCoinService sellCoinService;

    /**
     * 查询匹配总价(用户卖币，输入数量后，得到预计总价)
     * @param req
     * @return
     */
    @PostMapping("/queryMatchingTotalPrice")
    public PlatformResponse queryMatchingTotalPrice(@RequestBody @Valid QueryMatchingTotalPriceReq req) {
        return sellCoinService.queryMatchingTotalPrice(req);
    }

    /**
     * 发起卖币
     * @param req
     * @return
     */
    @PostMapping("/initialToSellCoin")
    public PlatformResponse initialToSellCoin(@RequestBody @Valid InitialToSellCoinReq req){
        return sellCoinService.initialToSellCoin(req);
    }

    /**
     * 商户端用户确认收款并放币
     * @param req
     * @return
     */
    @PostMapping("/confirmedReceiptAndCoinRelease")
    public PlatformResponse confirmedReceiptAndCoinRelease(@RequestBody @Valid ConfirmedReceiptAndCoinReleaseReq req){
        return sellCoinService.confirmedReceiptAndCoinRelease(req);
    }


    // TODO 需要给前端提供查询订单列表接口
    @PostMapping("/getOrderList")
    public PlatformResponse getOrderList(){
        return null;
    }




}
